package designPrinciple.dependencyInversion;

public class DependencyInversion2 {
    public static void main(String[] args) {
        Person2 person2 = new Person2();
        person2.receive(new Email2());
        person2.receive(new WeChat());
    }
}

interface IReceiver{
    public String getInfo();
}

class Email2 implements IReceiver{
    public String getInfo(){
        return "电子邮件信息：hello，world";
    }
}


class Person2{
    public void receive(IReceiver iReceiver){
        System.out.println(iReceiver.getInfo());
    }
}

//增加新的接收方式
class WeChat implements IReceiver{

    @Override
    public String getInfo() {
        return "微信 ：你好啊!!";
    }
}